package com.gitee.l0km.jsonvisitor.listener;

import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;

import com.gitee.l0km.jsonvisitor.exception.ParseException;

/**
 * 语法解析异常侦听器
 * @author guyadong
 *
 */
public class ParserErrorListener extends BaseErrorListener {

	/**
	 * 语法解析异常侦听器实例
	 */
	public static final ParserErrorListener INSTANCE = new ParserErrorListener();
	
	public ParserErrorListener() {
	}
	@Override
	public void syntaxError(Recognizer<?, ?> recognizer,
							Object offendingSymbol,
							int line,
							int charPositionInLine,
							String msg,
							RecognitionException e)
	{
		throw new ParseException("line " + line + ":" + charPositionInLine + " " + msg);
	}
}
